<template>
  <el-button @click="dClick" :disabled="disabled"><slot /></el-button>
</template>
<script>
  import { debounce } from 'lodash'
  export default {
    name: 'debounceBtn',
    emits: ['debounce'],
    props: {
      delay: {
        type: Number,
        default: 400,
      },
      disabled: {
        type: Boolean,
      },
    },
    setup(props, context) {
      const dClick = debounce(
        () => {
          console.log('disabled =' + props.disabled)
          context.emit('debounce')
        },
        props.delay,
        { leading: true, trailing: false }
      )
      return {
        dClick,
      }
    },
  }
</script>
